package seeders

import (
	"github.com/goravel/framework/facades"
	"goravel/app/models/userEntity"
)

type UserSeeder struct {
}

// Signature The name and signature of the seeder.
func (s *UserSeeder) Signature() string {
	return "UserSeeder"
}

// Run executes the seeder logic.
func (s *UserSeeder) Run() error {
	pwd := ""
	if facades.Hash().NeedsRehash("admin888") {
		//Hash加密
		pwd, _ = facades.Hash().Make("admin888")
	}
	user1 := userEntity.User{
		Username: "18888888888",
		Phone:    "18888888888",
		RealName: "小张",
		Password: pwd,
	}

	err := facades.Orm().Query().Create(&user1)
	if err != nil {
		return nil
	}
	user2 := userEntity.User{
		Username: "18888888889",
		Phone:    "18888888889",
		RealName: "小王",
		Password: pwd,
	}
	err = facades.Orm().Query().Create(&user2)
	if err != nil {
		return err
	}
	return nil
}
